package org.example.struct.array;

/**
 * @author liyishan
 * @date 2023/12/6 09:54
 * @apiNote
 */

public class Test00125IsPalindrome {
    public static void main(String[] args) {
        System.out.println(isPalindrome("A man, a plan, a canal: Panama"));
    }

    public static boolean isPalindrome(String s) {
        StringBuffer sgood = new StringBuffer();
        int length = s.length();
        for(int i=0; i<length; i++){
            char ch = s.charAt(i);
            if(Character.isLetterOrDigit(ch)){
                sgood.append(Character.toLowerCase(ch));
            }
        }
        StringBuffer sNew = new StringBuffer(sgood).reverse();
        return sgood.toString().equals(sNew.toString());
    }
}
